
import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:get/utils.dart';



class VersionUpdateView extends Dialog {
  final Function onTap;
  const VersionUpdateView(this.onTap, {super.key});
  
  @override
  Widget build(BuildContext context) {
    return SafeArea(child: Container(alignment: Alignment.topCenter, child: Container(
        height: 318,
        width: 270,
        padding: const EdgeInsets.only(left: 16, right: 16, top: 64),
        margin: const EdgeInsets.only(top: 110, left: 36, right: 36),
        decoration: const BoxDecoration(
          image: DecorationImage(image: AssetImage('images/version_update.png'), 
          fit: BoxFit.fill, 
          alignment: Alignment.topCenter,),
          // color: Colors.red
        ),
        child: Column(children: [
          Row(children: [const Spacer(), GestureDetector(onTap: () => {
            Navigator.pop(context)
          }, child: const Icon(Icons.cancel_outlined, color: Colors.white60, size: 20,))],),
          const Row(children: [Text('Judul', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold, color: Colors.white, decoration: TextDecoration.none))],),
          const SizedBox(height: 16,),
          const Expanded(child: Center(child: Text('1.Content content content content\n1.Content content content content', style: TextStyle(fontSize: 12, fontWeight: FontWeight.normal, color: Color(0xFF333333), decoration: TextDecoration.none)),)),
          TextButton(onPressed: (){
            Navigator.pop(context);
            onTap;
          }, 
          child: const Text('Perbarui sekarang', style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: Colors.white, decoration: TextDecoration.none)))
        ],)
      ),));
  }

  static showVersionUpdateAlert(BuildContext context, Function onTap) {
    return showGeneralDialog(
                  context: context,
                  pageBuilder: (context, anim1, anim2) { return Container(); },
                  barrierColor: const Color(0x80000000),
                  barrierDismissible: true,
                  barrierLabel: '',
                  transitionDuration: const Duration(milliseconds: 200),
                  transitionBuilder: (context, anim1, anim2, child) {
                    return Transform.scale(
                      scale: anim1.value,
                      child: VersionUpdateView(onTap),
                    );
                  });
  }
}